package com.example.ruiji.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ruiji.Dto.SetmealDto;
import com.example.ruiji.common.Result;
import com.example.ruiji.entity.Setmeal;
import com.example.ruiji.service.SetmealDishService;
import com.example.ruiji.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    @Autowired
    private SetmealDishService setmealDishService;

    @PostMapping
    public Result<String> save(@RequestBody SetmealDto setmealDto) {
        return setmealService.save(setmealDto);
    }

    @GetMapping("/page")
    public Result<Page<SetmealDto>> Page(int page, int pageSize, String name) {
        return setmealService.page(page, pageSize, name);
    }

    @DeleteMapping
    public Result<String> delete(@RequestParam List<Long> ids) {
        return setmealService.delete(ids);
    }

    @GetMapping("list")
    public Result<List<Setmeal>> list(Setmeal setmeal) {
        return setmealService.list(setmeal);
    }
}
